#e
#Title[zNuAũ[U[gbvv]
#Text[TCRXe[Lłi^q^j]
#ScriptVersion[2]

script_enemy_main
{
	let scroll=0;
	let flag=0;
	let flag2=0;
	let cx=GetCenterX();
	let cy=GetCenterY();
	let boss=GetCurrentScriptDirectory~"img\boss7-2.png";
	let eye=GetCurrentScriptDirectory~"img\bg7-1.png";
	let asa=GetCurrentScriptDirectory~"img\bg7-2.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetLife(600);
		SetDamageRate(10,0);
		SetInvincibility(240);
		LoadGraphic(boss);
		LoadGraphic(GetCurrentScriptDirectory~"img\enemy\magic.png");
		LoadGraphic(eye);
		LoadGraphic(asa);
		shottask;
		movetask;
		drawtask;
		SetEnemyMarker(false);
		MagicCircle(false);
		SetDurableSpellCard;
		SetShotAutoDeleteClip(400,400,400,400);
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
		DeleteGraphic(GetCurrentScriptDirectory~"img\enemy\magic.png");
		DeleteGraphic(boss);
		DeleteGraphic(eye);
		DeleteGraphic(asa);
		SetShotAutoDeleteClip(64,64,64,64);
	}
	@DrawLoop
	{
		SetTexture(boss);	
		if(flag==1)
		{
			SetGraphicRect(52,0,81,63);
		}
		else if(flag==2)
		{
			SetGraphicRect(24,0,52,63);
		}
		else
		{
			SetGraphicRect(0,0,24,63);
		}
		if(flag==3)
		{
			SetAlpha(0);
		}
		else
		{
			SetAlpha(255);
		}
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetX,GetY);
	}
	@BackGround
	{
		SetColor(128,128,128);
		SetTexture(eye);	
		SetGraphicRect(0,0,384,448);
		SetAlpha(255);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx,cy);
		SetColor(255,255,255);
		SetTexture(asa);	
		SetGraphicRect(0,0,888,189*5);
		SetAlpha(64);
		SetGraphicScale(0.5,0.75);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx+scroll,cy);
		DrawGraphic(cx+scroll-444,cy);
		if(scroll>444)
		{
			scroll=0;
		}
	}
	task shottask
	{
		wait(240);
		let y=GetClipMinY;
		loop(10)
		{
			CraateObjLaser(0,y,0,2,0,512,2);
			y-=10;
			wait(50);
		}
		let y=GetClipMinY;
		loop(10)
		{
			CraateObjLaser(448,y,0,2,225,700,2);
			wait(35);
			CraateObjLaser(0,y,0,2,315,700,2);
			y-=10;
			wait(35);
		}
			wait(240);
		let x=GetClipMinX;
		loop(10)
		{
			CraateObjLaser(x,0,2,0,135,700,2);
			wait(35);
			CraateObjLaser(x,480,2,0,225,700,2);
			x-=10;
			wait(35);
		}
		wait(180);
		let x=GetClipMinX;
		loop(5)
		{
			CraateObjLaser(448-x,0,-1,0,90,700,2);
			wait(50);
			CraateObjLaser(x,0,1,0,90,700,2);
			wait(50);
			x-=10;
		}
		wait(180);
		let y=GetClipMinY;
		let x=GetClipMinX;
		loop(5)
		{
			CraateObjLaser(448-x,0,-1,0,90,700,2);
			wait(50);
			CraateObjLaser(0,480-y,0,-1,0,512,2);
			wait(50);
			CraateObjLaser(x,0,1,0,90,700,2);
			x-=10;
			wait(50);
			CraateObjLaser(0,y,0,1,0,512,2);
			y-=10;
		}
		wait(300);
		let y=GetClipMinY-30;
		let x=GetClipMinY-30;
		CraateObjLaser(464-x,0,-1,0,90,700,2);
		CraateObjLaser(0,480-y,0,-1,0,512,2);
		CraateObjLaser(x,0,1,0,90,700,2);
		CraateObjLaser(0,y,0,1,0,512,2);
	}
	task movetask
	{
		wait(120);
		SetScore(30000);
		SetMovePosition02(cx,-30,60);
		SetTimer(77);
		PlaySE(GetCurrentScriptDirectory~"seUseSpellCard.wav");
		CutIn(YOUMU,"zNuAũ[U[gbvv",0,0,0,0,0);
	}
	task CraateObjLaser(let x,let y,let x2,let y2,angle,let length,let width)
	{
		let count = 0;
		let alpha = 0;
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj, x,y);
		Obj_SetSpeed(obj, 0);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 253);
		ObjShot_SetDelay(obj, 0);
		ObjLaser_SetLength(obj, length);
		ObjLaser_SetWidth(obj, width);
		Obj_SetCollisionToPlayer(obj,false);
		ObjLaser_SetSource(obj, false);
		while(!Obj_BeDeleted(obj))
		{
			if(length<GetClipMaxY+32)
			{
				length+=10;
				count--;
			}
			if(width>24)
			{
				Obj_SetCollisionToPlayer(obj,true);
			}
			else
			{
				Obj_SetCollisionToPlayer(obj,false);
			}
			if(count>30&&count<=34)
			{
				width+=8;
			}
			if(count>50&&count<=58)
			{
				width-=4;
			}
			if(count==60)
			{
				count=0;
			}
			x+=x2;
			y+=y2;
			ObjLaser_SetWidth(obj, width);
			ObjLaser_SetLength(obj, length);
			Obj_SetPosition(obj, x,y);
			count++;
			yield;
		}
	}
	task drawtask
	{
		let x=0;
		loop
		{	
			if(GetX>x+0.5)
			{
				flag=1;
			}
			else if(GetX<x-0.5)
			{
				flag=2;
			}
			else
			{
				flag=0;
			}
			if(GetTimer<79)
			{
				flag=3;
			}
			x=GetX;
			scroll++;
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}